/**
 * Copyright (c) 2012, SHX Studio.
 * All rights reserved.
 * rosary226@gmail.com
 * 
 * @author shenqianfeng
 * @date 2012-9-1  
 * @version 1.0   
 */

package com.xxx.sqfengine.primitives;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

import com.xxx.sqfengine.util.SQFGLBufferUtil;
import com.xxx.sqfengine.util.SQFGLColor4;
import com.xxx.sqfengine.util.SQFGLConstants;

public class SQFGLVertex {
	private float x;
	private float y;
	private float z;
	private SQFGLColor4 mColor;
	
	public SQFGLVertex(float x, float y, float z, SQFGLColor4 color) {
		this.x = x;
		this.y = y;
		this.z = z;
		this.mColor = (null == color) ? (new SQFGLColor4(255, 255, 255, 255)) : color;
	}
	
	public float x() {
		return x;
	}
	
	public float y() {
		return y;
	}
	
	public float z() {
		return z;
	}
	
	public SQFGLColor4 getColor() {
		return mColor;
	}

	public void setColor(SQFGLColor4 color) {
		this.mColor = color;
	}
	
	public FloatBuffer toVerticesFloatBuf() {
/*		ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2);
		ibb.order(ByteOrder.nativeOrder());
		indexBuffer = ibb.asShortBuffer();
		indexBuffer.put(indices);
		indexBuffer.position(0);*/
		
		ByteBuffer ibb = ByteBuffer.allocateDirect(3 * SQFGLBufferUtil.BYTES_PER_FLOAT);
		ibb.order(ByteOrder.nativeOrder());
		FloatBuffer fb = ibb.asFloatBuffer();
		fb.put(x);
		fb.put(y);
		fb.put(z);
		fb.position(0);
		fb.limit(3);
		return fb;
	}


}
